package com.cy.pj.common.Service.advisor;

import org.springframework.aop.support.StaticMethodMatcherPointcutAdvisor;
import org.springframework.stereotype.Component;

import java.lang.reflect.Method;

@Component
public class LogAdvisor extends StaticMethodMatcherPointcutAdvisor {
    public LogAdvisor(){
        setAdvice(new LogAdvice());
    }

    @Override
    public boolean matches(Method method, Class<?> aClass) {
        try {
            Method targetMethod =
            aClass.getMethod(method.getName(),method.getParameterTypes());
            return targetMethod.getName().equals("sendMail");
        } catch (Exception e) {
            return false;
        }
    }
}
